package com.shketai.service;

import java.util.List;

import com.shketai.dao.InfoDao;
import com.shketai.entity.Info;
import com.shketai.entity.PageBean;

public class InfoService {

	private InfoDao infoDao;

	public void setInfoDao(InfoDao infoDao) {
		this.infoDao = infoDao;
	}
	
	public void updateFlag(int id,String flags){
		infoDao.updateFlag(id, flags);
	}
	/**
	 * 批量更新缴费状态
	 * @param stu_id
	 * @param flag
	 */
	public void update(List<Integer> ids,int flag){
		infoDao.update(ids,flag);
	}
	public void quitSubject(int id) {
		infoDao.quitSubject(id);
	}
	
	public int addInfo(int stu_id,int classinfo_id){
		//选课之前，先判断时间段是否有冲突
				/*boolean flag = infoDao.checkPeriod(stu_id,classinfo_id);
				if(flag){
					//冲突了
					return 0;
				}else{*/
		infoDao.addInfo(stu_id, classinfo_id);
		return 1;
				
	}
	 public int getNum(int classinfo_id){
	    return infoDao.getNum(classinfo_id);
	}
	 
	public int checkstuid(int stu_id,int classinfo_id){
		int result = infoDao.checkstuid(stu_id,classinfo_id);
		return result;
	}
	
	public boolean checkPeriod(int stu_id, int classinfo_id) {
		boolean flag = infoDao.checkPeriod(stu_id, classinfo_id);
		return flag;
	}
	public int deleteById(int id){
		int result = infoDao.deleteById(id);
		return result;
	}
	public List<Info> findAllInfo(int user_id){
		return infoDao.findAllInfo(user_id);
	}

	public List<Info> findAllInfo1(int user_id) {
		return infoDao.findAllInfo1(user_id);
	}

	public List<Info> findAllInfo2(int user_id) {
		return infoDao.findAllInfo2(user_id);
	}

	public List<Info> findAllInfo3(int user_id) {
		return infoDao.findAllInfo3(user_id);
	}
	
	 public PageBean<Info> findAllInfo4(int page) {
		 PageBean<Info> pb = new PageBean<Info>();
		 List<Info> list = infoDao.findAllInfo4(page);
		 pb.setDatas(list);
			int total = infoDao.findCount();
			pb.setTotal(total);
			return pb;
	}
	 public PageBean<Info> findAllInfo5(int page) {
		 PageBean<Info> pb = new PageBean<Info>();
		 List<Info> list = infoDao.findAllInfo5(page);
		 pb.setDatas(list);
			int total = infoDao.findCount1();
			pb.setTotal(total);
			return pb;
	}
	 
	 public PageBean<Info> findAllInfo6(int page) {
		 PageBean<Info> pb = new PageBean<Info>();
		 List<Info> list = infoDao.findAllInfo6(page);
		 pb.setDatas(list);
			int total = infoDao.findCount2();
			pb.setTotal(total);
			return pb;
	}
	public List<Info> findById(int stu_id){
		return infoDao.findById(stu_id);
	}

	public PageBean<Info> findByClassinfoId(int classinfo_id,int page) {
		PageBean<Info> pb = new PageBean<Info>();
		List<Info> list = infoDao.findByClassinfoId(classinfo_id, page);
		pb.setDatas(list);
		int total = infoDao.findCount(classinfo_id);
		pb.setTotal(total);
		return pb;
	}
	
	public PageBean<Info> findByClassinfoId1(int classinfo_id,int page) {
		PageBean<Info> pb = new PageBean<Info>();
		List<Info> list = infoDao.findByClassinfoId1(classinfo_id, page);
		pb.setDatas(list);
		int total = infoDao.findCount1(classinfo_id);
		pb.setTotal(total);
		return pb;
	}
	
	public List<Info> findAll(int classinfo_id){
		List list = infoDao.findAll(classinfo_id);
		return list;
	}
	public List<Object[]> findAllByclassId(int classinfo_id){
		List<Object[]> list =  infoDao.findAllByclassId(classinfo_id);
		return list;
	}
	
	public List<Object[]> findAllBySubject(){
		List<Object[]> list =  infoDao.findAllBySubject();
		return list;
	}
	public List<Info> find(int user_id){
		List list = infoDao.find(user_id);
		return list;
	}
	
	public List<Info> queryByUsername1(String stuName){
		return infoDao.queryByUsername1(stuName);
	}
	
	public List<Info> queryByUsername2(String stuName){
		return infoDao.queryByUsername2(stuName);
	}
	
	public List<Info> queryByUsername3(String stuName){
		return infoDao.queryByUsername3(stuName);
	}
}
